package com.laf.sinaweibo.androidtest;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MainService extends Service {

	private IBinder mBinder;
	
	@Override
	public IBinder onBind(Intent intent) {
		
		Log.i("laf", "onBind()");
		mBinder = new MyBinder();
		return mBinder;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		Log.i("laf", "onCreate()");
	}
	
	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		Log.i("laf", "onStartCommand()");
		return super.onStartCommand(intent, flags, startId);
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		Log.i("laf", "onDestroy()");
	}
	
	private int add1(int a , int b) {
		Log.i("laf", "MainService: add1()");
		return a + b;
	}
	
	class MyBinder extends Binder implements IService {

		@Override
		public int add(int a, int b) {
			Log.i("laf", "MyBinder: add()");
			return add1(a, b);
		}
		
	}
}
